package com.lemontree.spring.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.lang.annotation.Annotation;

@Component
@Aspect
public class AspectAroundTest implements Order{

    @Around("execution(* greetTo(..)) && args(age,name)")
    public int aroundT(ProceedingJoinPoint joinPoint,int age,String name) throws Throwable {
        System.out.println("joinPoint---------------");
        System.out.println("arg: "+joinPoint.getArgs()[0]);
        joinPoint.proceed();
        System.out.println("signature: "+ ((MethodSignature)joinPoint.getSignature()).getParameterTypes());
        System.out.println("target: "+joinPoint.getTarget().getClass().getName());
        System.out.println("joinPoint---------------");
        return 1;
    }

    @Around("execution(* greetTo(..)) && args(age,name)")
    public int xxsss(ProceedingJoinPoint joinPoint,int age,String name) throws Throwable {
        System.out.println("joinPoint--------------222-");
        System.out.println("arg: "+joinPoint.getArgs()[0]);
        joinPoint.proceed();
        System.out.println("signature: "+ ((MethodSignature)joinPoint.getSignature()).getParameterTypes());
        System.out.println("target: "+joinPoint.getTarget().getClass().getName());
        System.out.println("joinPoint---------------");
        return 1;
    }

    @Override
    public int value() {
        return 100;
    }

    @Override
    public Class<? extends Annotation> annotationType() {
        return null;
    }
}
